/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PurchaseOrderFrame.java
 *
 * Created on 26 Des 12, 22:32:59
 */
package com.ivanbiz.gui;

import com.ivanbiz.dao.ItemDAO;
import com.ivanbiz.dao.PurchaseOrderDAO;
import com.ivanbiz.dao.PurchaseOrderItemDAO;
import com.ivanbiz.dao.SupplierDAO;
import com.ivanbiz.dao.UserDAO;
import com.ivanbiz.dao.impl.ItemDAOImpl;
import com.ivanbiz.dao.impl.PurchaseOrderDAOImpl;
import com.ivanbiz.dao.impl.PurchaseOrderItemDAOImpl;
import com.ivanbiz.dao.impl.SupplierDAOImpl;
import com.ivanbiz.dao.impl.UserDAOImpl;
import com.ivanbiz.helper.GlobalConstant;
import com.ivanbiz.helper.MyUniqueNumber;
import com.ivanbiz.helper.ServiceHelper;
import com.ivanbiz.helper.UserSession;
import com.ivanbiz.model.GudangItem;
import com.ivanbiz.model.PurchaseOrder;
import com.ivanbiz.model.PurchaseOrderItem;
import com.ivanbiz.model.Supplier;
import com.ivanbiz.model.User;
import com.ivanbiz.report.PurchaseOrderReport;
import java.awt.event.KeyEvent;
import java.math.BigDecimal;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;

/**
 *
 * @author Administrator
 */
public class PurchaseOrderFrame extends javax.swing.JInternalFrame {

    PurchaseOrderDAO purchaseOrderDAO = new PurchaseOrderDAOImpl();
    PurchaseOrderItemDAO purchaseOrderItemDAO = new PurchaseOrderItemDAOImpl();
    ItemDAO itemDAO = new ItemDAOImpl();
    UserDAO userDAO = new UserDAOImpl();
    SupplierDAO supplierDAO = new SupplierDAOImpl();
    List<PurchaseOrder> listPurchaseOrder = new ArrayList<PurchaseOrder>();
    List<PurchaseOrderItem> listPurchaseOrderItem = new ArrayList<PurchaseOrderItem>();
    List<User> listUser = new ArrayList<User>();
    List<Supplier> listSupplier = new ArrayList<Supplier>();
    User user = UserSession.getUser();
    ServiceHelper serviceHelper = new ServiceHelper();
    NumberFormat numberFormat = NumberFormat.getInstance(Locale.US);
    double totals = 0;

    /** Creates new form PurchaseOrderFrame */
    public PurchaseOrderFrame() {
        initComponents();
        setVisible(true);
        listPurchaseOrderItem.clear();
        updateData();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel2 = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        textNoPO = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        datePO = new org.jdesktop.swingx.JXDatePicker();
        comboUser = new javax.swing.JComboBox();
        comboSupplier = new javax.swing.JComboBox();
        jPanel5 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tableData = new javax.swing.JTable();
        jPanel6 = new javax.swing.JPanel();
        buttonDelete = new javax.swing.JButton();
        buttonUpdate = new javax.swing.JButton();
        buttonReset = new javax.swing.JButton();
        buttonSave = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jPanel3 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        textKodeBarcode = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        textNamaItem = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        textDescription = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        textHargaModal = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        textDiskon1 = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        textDiskon3 = new javax.swing.JTextField();
        textDiskon2 = new javax.swing.JTextField();
        textDiskon4 = new javax.swing.JTextField();
        textSubtotal = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        textQuantity = new javax.swing.JTextField();
        jLabel27 = new javax.swing.JLabel();
        jLabel28 = new javax.swing.JLabel();
        jLabel29 = new javax.swing.JLabel();
        jLabel30 = new javax.swing.JLabel();
        jPanel7 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        tableData1 = new javax.swing.JTable();
        jPanel9 = new javax.swing.JPanel();
        buttonDelete2 = new javax.swing.JButton();
        buttonUpdate2 = new javax.swing.JButton();
        buttonReset2 = new javax.swing.JButton();
        buttonSave2 = new javax.swing.JButton();
        buttonPrint = new javax.swing.JButton();
        jPanel8 = new javax.swing.JPanel();
        comboSearch = new javax.swing.JComboBox();
        textSearch = new javax.swing.JTextField();
        jPanel11 = new javax.swing.JPanel();
        comboNoPO = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        boxTunai = new javax.swing.JCheckBox();
        boxCredit = new javax.swing.JCheckBox();
        dateJatuhTempo = new org.jdesktop.swingx.JXDatePicker();
        jPanel12 = new javax.swing.JPanel();
        textTotal = new javax.swing.JTextField();

        setClosable(true);
        setTitle("Purchase Order");

        jTabbedPane1.setFont(new java.awt.Font("Monospaced", 1, 14));

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Input", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Monospaced", 0, 11))); // NOI18N

        textNoPO.setFont(new java.awt.Font("Monospaced", 1, 14));

        jLabel1.setFont(new java.awt.Font("Monospaced", 1, 14));
        jLabel1.setText("No PO");

        jLabel2.setFont(new java.awt.Font("Monospaced", 1, 14));
        jLabel2.setText("Tgl PO");

        jLabel3.setFont(new java.awt.Font("Monospaced", 1, 14));
        jLabel3.setText("User");

        jLabel14.setFont(new java.awt.Font("Monospaced", 1, 14));
        jLabel14.setText("Suplier");

        datePO.setFont(new java.awt.Font("Monospaced", 1, 14));

        comboUser.setFont(new java.awt.Font("Monospaced", 1, 14));

        comboSupplier.setFont(new java.awt.Font("Monospaced", 1, 14));

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3)
                    .addComponent(jLabel2)
                    .addComponent(jLabel1)
                    .addComponent(jLabel14))
                .addGap(36, 36, 36)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(comboUser, 0, 0, Short.MAX_VALUE)
                    .addComponent(datePO, javax.swing.GroupLayout.DEFAULT_SIZE, 675, Short.MAX_VALUE)
                    .addComponent(textNoPO, javax.swing.GroupLayout.DEFAULT_SIZE, 675, Short.MAX_VALUE)
                    .addComponent(comboSupplier, javax.swing.GroupLayout.Alignment.TRAILING, 0, 675, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(textNoPO, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(datePO, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(comboUser, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(8, 8, 8)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(comboSupplier, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel14))
                .addContainerGap())
        );

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Table Data", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Monospaced", 0, 11))); // NOI18N

        tableData.setAutoCreateRowSorter(true);
        tableData.setFont(new java.awt.Font("Monospaced", 1, 14));
        tableData.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tableData.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tableDataMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(tableData);

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 767, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 418, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Button", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Monospaced", 0, 11))); // NOI18N

        buttonDelete.setFont(new java.awt.Font("Monospaced", 1, 14));
        buttonDelete.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/ivanbiz/gui/icon/delete.jpg"))); // NOI18N
        buttonDelete.setText("Hapus");
        buttonDelete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonDeleteActionPerformed(evt);
            }
        });

        buttonUpdate.setFont(new java.awt.Font("Monospaced", 1, 14));
        buttonUpdate.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/ivanbiz/gui/icon/Edit.jpg"))); // NOI18N
        buttonUpdate.setText("Edit");
        buttonUpdate.setPreferredSize(new java.awt.Dimension(70, 23));
        buttonUpdate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonUpdateActionPerformed(evt);
            }
        });

        buttonReset.setFont(new java.awt.Font("Monospaced", 1, 14));
        buttonReset.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/ivanbiz/gui/icon/Reset.jpg"))); // NOI18N
        buttonReset.setText("Reset");
        buttonReset.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonResetActionPerformed(evt);
            }
        });

        buttonSave.setFont(new java.awt.Font("Monospaced", 1, 14));
        buttonSave.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/ivanbiz/gui/icon/save.jpg"))); // NOI18N
        buttonSave.setText("Simpan");
        buttonSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonSaveActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(buttonSave, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonUpdate, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonDelete, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonReset, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(buttonReset, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(buttonDelete, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(buttonUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(buttonSave, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Purchase Order", jPanel2);

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Input", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Monospaced", 0, 11))); // NOI18N

        jLabel5.setFont(new java.awt.Font("Monospaced", 1, 14));
        jLabel5.setText("Kode Barcode");

        textKodeBarcode.setEditable(false);
        textKodeBarcode.setFont(new java.awt.Font("Monospaced", 1, 14));

        jLabel6.setFont(new java.awt.Font("Monospaced", 1, 14));
        jLabel6.setText("Nama Item");

        textNamaItem.setEditable(false);
        textNamaItem.setFont(new java.awt.Font("Monospaced", 1, 14));

        jLabel7.setFont(new java.awt.Font("Monospaced", 1, 14));
        jLabel7.setText("Description");

        textDescription.setFont(new java.awt.Font("Monospaced", 1, 14));

        jLabel8.setFont(new java.awt.Font("Monospaced", 1, 14));
        jLabel8.setText("Harga Modal");

        textHargaModal.setFont(new java.awt.Font("Monospaced", 1, 14));
        textHargaModal.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                textHargaModalKeyReleased(evt);
            }
        });

        jLabel9.setFont(new java.awt.Font("Monospaced", 1, 14)); // NOI18N
        jLabel9.setText("Diskon 1");

        textDiskon1.setFont(new java.awt.Font("Monospaced", 1, 14)); // NOI18N
        textDiskon1.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                textDiskon1KeyReleased(evt);
            }
        });

        jLabel10.setFont(new java.awt.Font("Monospaced", 1, 14)); // NOI18N
        jLabel10.setText("Diskon 3");

        jLabel11.setFont(new java.awt.Font("Monospaced", 1, 14)); // NOI18N
        jLabel11.setText("Diskon 2");

        textDiskon3.setFont(new java.awt.Font("Monospaced", 1, 14)); // NOI18N
        textDiskon3.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                textDiskon3KeyReleased(evt);
            }
        });

        textDiskon2.setFont(new java.awt.Font("Monospaced", 1, 14)); // NOI18N
        textDiskon2.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                textDiskon2KeyReleased(evt);
            }
        });

        textDiskon4.setFont(new java.awt.Font("Monospaced", 1, 14));
        textDiskon4.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                textDiskon4KeyReleased(evt);
            }
        });

        textSubtotal.setEditable(false);
        textSubtotal.setFont(new java.awt.Font("Monospaced", 1, 14));

        jLabel13.setFont(new java.awt.Font("Monospaced", 1, 14));
        jLabel13.setText("Subtotal");

        jLabel12.setFont(new java.awt.Font("Monospaced", 1, 14));
        jLabel12.setText("Diskon 4");

        jLabel15.setFont(new java.awt.Font("Monospaced", 1, 14));
        jLabel15.setText("Quantity");

        textQuantity.setFont(new java.awt.Font("Monospaced", 1, 14));
        textQuantity.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                textQuantityKeyReleased(evt);
            }
        });

        jLabel27.setFont(new java.awt.Font("Monospaced", 1, 14));
        jLabel27.setText("%");

        jLabel28.setFont(new java.awt.Font("Monospaced", 1, 14));
        jLabel28.setText("%");

        jLabel29.setFont(new java.awt.Font("Monospaced", 1, 14));
        jLabel29.setText("%");

        jLabel30.setFont(new java.awt.Font("Monospaced", 1, 14));
        jLabel30.setText("%");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel6)
                    .addComponent(jLabel5)
                    .addComponent(jLabel7))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(textDescription, javax.swing.GroupLayout.DEFAULT_SIZE, 328, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                        .addComponent(textNamaItem, javax.swing.GroupLayout.DEFAULT_SIZE, 183, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel15)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textQuantity, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                        .addComponent(textKodeBarcode, javax.swing.GroupLayout.DEFAULT_SIZE, 99, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textHargaModal, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel10)
                    .addComponent(jLabel13)
                    .addComponent(jLabel9, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(textDiskon1)
                            .addComponent(textDiskon3, javax.swing.GroupLayout.DEFAULT_SIZE, 74, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel28)
                            .addComponent(jLabel27))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(jLabel12)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(textDiskon4, javax.swing.GroupLayout.DEFAULT_SIZE, 69, Short.MAX_VALUE))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(jLabel11)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(textDiskon2, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE))))
                    .addComponent(textSubtotal))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel30)
                    .addComponent(jLabel29))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(textKodeBarcode, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel9)
                            .addComponent(textHargaModal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel8))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6)
                            .addComponent(textNamaItem, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel10)
                            .addComponent(textQuantity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel15))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(textDescription, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jLabel13)
                                .addComponent(jLabel7))))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(textDiskon1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel11)
                            .addComponent(textDiskon2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel30)
                            .addComponent(jLabel27))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(textDiskon4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel12)
                            .addComponent(jLabel29)
                            .addComponent(jLabel28)
                            .addComponent(textDiskon3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(textSubtotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Table Data", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Monospaced", 0, 11))); // NOI18N

        tableData1.setAutoCreateRowSorter(true);
        tableData1.setFont(new java.awt.Font("Monospaced", 1, 14));
        tableData1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tableData1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tableData1MouseClicked(evt);
            }
        });
        jScrollPane2.setViewportView(tableData1);

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 767, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 253, Short.MAX_VALUE)
                .addContainerGap())
        );

        jPanel9.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Button", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Monospaced", 0, 11))); // NOI18N

        buttonDelete2.setFont(new java.awt.Font("Monospaced", 1, 14));
        buttonDelete2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/ivanbiz/gui/icon/delete.jpg"))); // NOI18N
        buttonDelete2.setText("Hapus");
        buttonDelete2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonDelete2ActionPerformed(evt);
            }
        });

        buttonUpdate2.setFont(new java.awt.Font("Monospaced", 1, 14));
        buttonUpdate2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/ivanbiz/gui/icon/Edit.jpg"))); // NOI18N
        buttonUpdate2.setText("Edit");
        buttonUpdate2.setPreferredSize(new java.awt.Dimension(70, 23));
        buttonUpdate2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonUpdate2ActionPerformed(evt);
            }
        });

        buttonReset2.setFont(new java.awt.Font("Monospaced", 1, 14));
        buttonReset2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/ivanbiz/gui/icon/Reset.jpg"))); // NOI18N
        buttonReset2.setText("Reset");
        buttonReset2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonReset2ActionPerformed(evt);
            }
        });

        buttonSave2.setFont(new java.awt.Font("Monospaced", 1, 14));
        buttonSave2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/ivanbiz/gui/icon/save.jpg"))); // NOI18N
        buttonSave2.setText("Simpan");
        buttonSave2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonSave2ActionPerformed(evt);
            }
        });

        buttonPrint.setFont(new java.awt.Font("Monospaced", 1, 14));
        buttonPrint.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/ivanbiz/gui/icon/Print.jpg"))); // NOI18N
        buttonPrint.setText("Print");
        buttonPrint.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buttonPrintActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(buttonSave2, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonUpdate2, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonDelete2, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonReset2, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(buttonPrint, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup()
                .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(buttonReset2, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(buttonDelete2, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(buttonUpdate2, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(buttonSave2, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(buttonPrint, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Search", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Monospaced", 0, 11))); // NOI18N

        comboSearch.setFont(new java.awt.Font("Monospaced", 1, 14));

        textSearch.setFont(new java.awt.Font("Monospaced", 1, 14));
        textSearch.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                textSearchKeyReleased(evt);
            }
        });

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(comboSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 164, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(textSearch, javax.swing.GroupLayout.DEFAULT_SIZE, 597, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(comboSearch, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel11.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Input", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Monospaced", 0, 11))); // NOI18N

        comboNoPO.setFont(new java.awt.Font("Monospaced", 1, 14));
        comboNoPO.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                comboNoPOKeyPressed(evt);
            }
        });

        jLabel4.setFont(new java.awt.Font("Monospaced", 1, 14));
        jLabel4.setText("No PO");

        jLabel19.setFont(new java.awt.Font("Monospaced", 1, 14));
        jLabel19.setText("> Jatuh Tempo");

        buttonGroup1.add(boxTunai);
        boxTunai.setFont(new java.awt.Font("Monospaced", 1, 14));
        boxTunai.setText("Tunai");
        boxTunai.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                boxTunaiActionPerformed(evt);
            }
        });

        buttonGroup1.add(boxCredit);
        boxCredit.setFont(new java.awt.Font("Monospaced", 1, 14));
        boxCredit.setText("Kredit");
        boxCredit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                boxCreditActionPerformed(evt);
            }
        });

        dateJatuhTempo.setFont(new java.awt.Font("Monospaced", 1, 14));

        javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11);
        jPanel11.setLayout(jPanel11Layout);
        jPanel11Layout.setHorizontalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(comboNoPO, 0, 330, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(boxTunai)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(boxCredit)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel19)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(dateJatuhTempo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel11Layout.setVerticalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel4)
                        .addComponent(comboNoPO, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(dateJatuhTempo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(boxTunai)
                        .addComponent(boxCredit)
                        .addComponent(jLabel19)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel12.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Total", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Monospaced", 0, 11))); // NOI18N

        textTotal.setFont(new java.awt.Font("Monospaced", 1, 24));
        textTotal.setHorizontalAlignment(javax.swing.JTextField.RIGHT);

        javax.swing.GroupLayout jPanel12Layout = new javax.swing.GroupLayout(jPanel12);
        jPanel12.setLayout(jPanel12Layout);
        jPanel12Layout.setHorizontalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel12Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(textTotal, javax.swing.GroupLayout.DEFAULT_SIZE, 767, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel12Layout.setVerticalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel12Layout.createSequentialGroup()
                .addComponent(textTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel7, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel11, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel8, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jPanel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Purchase Order Item", jPanel1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 824, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 776, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void buttonDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonDeleteActionPerformed
        int response = JOptionPane.showConfirmDialog(null, GlobalConstant.PROCCESS, GlobalConstant.CONFIRM, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
        if (response == JOptionPane.YES_OPTION) {
            try {
                PurchaseOrder purchaseOrder = listPurchaseOrder.get(tableData.getSelectedRow());
                purchaseOrderDAO.delete(purchaseOrder);
                JOptionPane.showMessageDialog(this, GlobalConstant.MSG_DELETE);
                updateData();
            } catch (Exception ex) {
                Logger.getLogger(PurchaseOrderFrame.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
}//GEN-LAST:event_buttonDeleteActionPerformed

    private void buttonUpdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonUpdateActionPerformed
        int response = JOptionPane.showConfirmDialog(null, GlobalConstant.PROCCESS, GlobalConstant.CONFIRM, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
        if (response == JOptionPane.YES_OPTION) {
            try {
                PurchaseOrder purchaseOrder = listPurchaseOrder.get(tableData.getSelectedRow());
                purchaseOrder.setNomerPO(textNoPO.getText());
                purchaseOrder.setTanggalPO(serviceHelper.getDateFormat(datePO.getDate()));
                purchaseOrder.setUser(user);
                purchaseOrder.setSupplier((Supplier) listSupplier.get(comboSupplier.getSelectedIndex()));
                purchaseOrder.setStatus(GlobalConstant.N);
                purchaseOrder.setUpdatedBy(user.getUserName());
                purchaseOrder.setUpdatedDate(new Date());
                purchaseOrderDAO.update(purchaseOrder);
                JOptionPane.showMessageDialog(this, GlobalConstant.MSG_UPDATE);
                updateData();
            } catch (Exception ex) {
                Logger.getLogger(PurchaseOrderFrame.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
}//GEN-LAST:event_buttonUpdateActionPerformed

    private void buttonResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonResetActionPerformed
        updateData();
}//GEN-LAST:event_buttonResetActionPerformed

    private void buttonSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSaveActionPerformed
        int response = JOptionPane.showConfirmDialog(null, GlobalConstant.PROCCESS, GlobalConstant.CONFIRM, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
        if (response == JOptionPane.YES_OPTION) {
            try {
                PurchaseOrder status = (PurchaseOrder) purchaseOrderDAO.getDataByEqual(PurchaseOrder.class, "nomerPO", textNoPO.getText());
                if (null != status) {
                    JOptionPane.showMessageDialog(this, jLabel1.getText() + GlobalConstant.SPACE + GlobalConstant.MSG_EXIST);
                } else {
                    PurchaseOrder purchaseOrder = new PurchaseOrder();
                    purchaseOrder.setNomerPO(textNoPO.getText());
                    purchaseOrder.setTanggalPO(serviceHelper.getDateFormat(datePO.getDate()));
                    purchaseOrder.setUser(user);
                    purchaseOrder.setSupplier((Supplier) listSupplier.get(comboSupplier.getSelectedIndex()));
                    purchaseOrder.setStatus(GlobalConstant.N);
                    purchaseOrder.setCreatedBy(user.getUserName());
                    purchaseOrder.setCreatedDate(new Date());
                    purchaseOrderDAO.save(purchaseOrder);
                    JOptionPane.showMessageDialog(this, GlobalConstant.MSG_SAVE);
                    updateData();
                }
            } catch (Exception ex) {
                Logger.getLogger(PurchaseOrderFrame.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
}//GEN-LAST:event_buttonSaveActionPerformed

    private void tableDataMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tableDataMouseClicked
        PurchaseOrder purchaseOrder = listPurchaseOrder.get(tableData.getSelectedRow());
        textNoPO.setText(purchaseOrder.getNomerPO());
        datePO.setDate(purchaseOrder.getTanggalPO());
        comboSupplier.setSelectedItem(purchaseOrder.getSupplier().getNama());
    }//GEN-LAST:event_tableDataMouseClicked

    private void comboNoPOKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_comboNoPOKeyPressed
        try {
            listPurchaseOrderItem = purchaseOrderItemDAO.getDataByEquals(PurchaseOrderItem.class, "nomerPO", (String) comboNoPO.getSelectedItem());
            PurchaseOrder purchaseOrder = listPurchaseOrder.get(comboNoPO.getSelectedIndex());
            if (purchaseOrder.getPembayaran() != null) {
                if (purchaseOrder.getPembayaran().equals(boxTunai.getText())) {
                    boxTunai.setSelected(true);
                } else {
                    boxCredit.setSelected(true);
                    jLabel19.setVisible(true);
                    dateJatuhTempo.setVisible(true);
                }
            }
            updateTable1();
            updateTotal();
        } catch (Exception ex) {
            Logger.getLogger(PurchaseOrderFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
}//GEN-LAST:event_comboNoPOKeyPressed

    private void textSearchKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_textSearchKeyReleased
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            try {
                GudangItem item = (GudangItem) itemDAO.getDataByEqual(GudangItem.class, (String) comboSearch.getSelectedItem(), textSearch.getText());
                if (item != null) {
                    textKodeBarcode.setText(item.getKodeBarcode());
                    textNamaItem.setText(item.getNamaItem());
                    textDescription.setText(item.getDescription());
                } else {
                    JOptionPane.showMessageDialog(this, (String) comboSearch.getSelectedItem() + GlobalConstant.SPACE + GlobalConstant.MSG_NOT_EXIST);
                }
            } //        try {
            //            listPurchaseOrderItem = purchaseOrderItemDAO.getDataByLike(PurchaseOrderItem.class, (String) comboSearch.getSelectedItem(), textSearch.getText());
            //            updateTable1();
            //        } catch (Exception ex) {
            //            Logger.getLogger(PurchaseOrderFrame.class.getName()).log(Level.SEVERE, null, ex);
            //        }
            catch (Exception ex) {
                Logger.getLogger(PurchaseOrderFrame.class.getName()).log(Level.SEVERE, null, ex);
            }
        }


        //        try {
        //            listPurchaseOrderItem = purchaseOrderItemDAO.getDataByLike(PurchaseOrderItem.class, (String) comboSearch.getSelectedItem(), textSearch.getText());
        //            updateTable1();
        //        } catch (Exception ex) {
        //            Logger.getLogger(PurchaseOrderFrame.class.getName()).log(Level.SEVERE, null, ex);
        //        }
}//GEN-LAST:event_textSearchKeyReleased

    private void buttonPrintActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonPrintActionPerformed
        try {
            List<PurchaseOrderItem> listNoPo = purchaseOrderItemDAO.getDataByEquals(PurchaseOrderItem.class, "nomerPO", (String) comboNoPO.getSelectedItem());
            PurchaseOrder purchaseOrder = (PurchaseOrder) purchaseOrderDAO.getDataByEqual(PurchaseOrder.class, "nomerPO", (String) comboNoPO.getSelectedItem());
            PurchaseOrderReport purchaseOrderReport = new PurchaseOrderReport();
            purchaseOrderReport.printPurchaseOrderItem(listNoPo, purchaseOrder);
            updateData();
        } catch (Exception ex) {
            Logger.getLogger(PurchaseOrderFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
}//GEN-LAST:event_buttonPrintActionPerformed

    private void buttonSave2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSave2ActionPerformed
        int response = JOptionPane.showConfirmDialog(null, GlobalConstant.PROCCESS, GlobalConstant.CONFIRM, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
        if (response == JOptionPane.YES_OPTION) {
            try {
                PurchaseOrderItem purchaseOrderItem = new PurchaseOrderItem();
                purchaseOrderItem.setNomerPO((String) comboNoPO.getSelectedItem());
                purchaseOrderItem.setKodeBarcode(textKodeBarcode.getText());
                purchaseOrderItem.setNamaItem(textNamaItem.getText());
                purchaseOrderItem.setDescription(textDescription.getText());
                purchaseOrderItem.setQuantity(textQuantity.getText().equals(GlobalConstant.EMPTY_STRING) ? Integer.parseInt(GlobalConstant.NOL) : Integer.parseInt(textQuantity.getText()));
                purchaseOrderItem.setHargaModal(textHargaModal.getText().equals(GlobalConstant.EMPTY_STRING) ? Double.parseDouble(GlobalConstant.NOL) : Double.parseDouble(textHargaModal.getText()));
                purchaseOrderItem.setDiskon1(textDiskon1.getText().equals(GlobalConstant.EMPTY_STRING) ? Float.parseFloat(GlobalConstant.NOL) : Float.parseFloat(textDiskon1.getText()));
                purchaseOrderItem.setDiskon2(textDiskon3.getText().equals(GlobalConstant.EMPTY_STRING) ? Float.parseFloat(GlobalConstant.NOL) : Float.parseFloat(textDiskon3.getText()));
                purchaseOrderItem.setDiskon3(textDiskon2.getText().equals(GlobalConstant.EMPTY_STRING) ? Float.parseFloat(GlobalConstant.NOL) : Float.parseFloat(textDiskon2.getText()));
                purchaseOrderItem.setDiskon4(textDiskon4.getText().equals(GlobalConstant.EMPTY_STRING) ? Float.parseFloat(GlobalConstant.NOL) : Float.parseFloat(textDiskon4.getText()));
                purchaseOrderItem.setSubTotal(textSubtotal.getText().equals(GlobalConstant.EMPTY_STRING) ? Double.parseDouble(GlobalConstant.NOL) : Double.parseDouble(textSubtotal.getText()));
                purchaseOrderItem.setCreatedBy(user.getUserName());
                purchaseOrderItem.setCreatedDate(new Date());
                PurchaseOrder purchaseOrder = listPurchaseOrder.get(comboNoPO.getSelectedIndex());
                if (boxTunai.isSelected()) {
                    purchaseOrder.setPembayaran(boxTunai.getText());
                }
                if (boxCredit.isSelected()) {
                    purchaseOrder.setPembayaran(boxCredit.getText());
                }
                if (purchaseOrder.getPembayaran() == null) {
                    JOptionPane.showMessageDialog(this, "Tipe pembayaran Belum dipilih !!!");
                    return;
                }
                purchaseOrder.setJatuhTempo(dateJatuhTempo.getDate());
                purchaseOrder.setTotal(totals + purchaseOrderItem.getSubTotal());
                purchaseOrderItemDAO.save(purchaseOrderItem, purchaseOrder);
                JOptionPane.showMessageDialog(this, GlobalConstant.MSG_SAVE);
                listPurchaseOrderItem = purchaseOrderItemDAO.getDataByEquals(PurchaseOrderItem.class, "nomerPO", (String) comboNoPO.getSelectedItem());
                totals = 0;
                updateData();
            } catch (Exception ex) {
                Logger.getLogger(PurchaseOrderFrame.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
}//GEN-LAST:event_buttonSave2ActionPerformed

    private void buttonReset2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonReset2ActionPerformed
        listPurchaseOrderItem.clear();
        updateData();
}//GEN-LAST:event_buttonReset2ActionPerformed

    private void buttonUpdate2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonUpdate2ActionPerformed
        int response = JOptionPane.showConfirmDialog(null, GlobalConstant.PROCCESS, GlobalConstant.CONFIRM, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
        if (response == JOptionPane.YES_OPTION) {
            try {
                PurchaseOrderItem purchaseOrderItem = listPurchaseOrderItem.get(tableData1.getSelectedRow());
                purchaseOrderItem.setNomerPO((String) comboNoPO.getSelectedItem());
                purchaseOrderItem.setKodeBarcode(textKodeBarcode.getText());
                purchaseOrderItem.setNamaItem(textNamaItem.getText());
                purchaseOrderItem.setDescription(textDescription.getText());
                purchaseOrderItem.setQuantity(textQuantity.getText().equals(GlobalConstant.EMPTY_STRING) ? Integer.parseInt(GlobalConstant.NOL) : Integer.parseInt(textQuantity.getText()));
                purchaseOrderItem.setHargaModal(textHargaModal.getText().equals(GlobalConstant.EMPTY_STRING) ? Double.parseDouble(GlobalConstant.NOL) : Double.parseDouble(textHargaModal.getText()));
                purchaseOrderItem.setDiskon1(textDiskon1.getText().equals(GlobalConstant.EMPTY_STRING) ? Float.parseFloat(GlobalConstant.NOL) : Float.parseFloat(textDiskon1.getText()));
                purchaseOrderItem.setDiskon2(textDiskon3.getText().equals(GlobalConstant.EMPTY_STRING) ? Float.parseFloat(GlobalConstant.NOL) : Float.parseFloat(textDiskon3.getText()));
                purchaseOrderItem.setDiskon3(textDiskon2.getText().equals(GlobalConstant.EMPTY_STRING) ? Float.parseFloat(GlobalConstant.NOL) : Float.parseFloat(textDiskon2.getText()));
                purchaseOrderItem.setDiskon4(textDiskon4.getText().equals(GlobalConstant.EMPTY_STRING) ? Float.parseFloat(GlobalConstant.NOL) : Float.parseFloat(textDiskon4.getText()));
                purchaseOrderItem.setSubTotal(textSubtotal.getText().equals(GlobalConstant.EMPTY_STRING) ? Double.parseDouble(GlobalConstant.NOL) : Double.parseDouble(textSubtotal.getText()));
                purchaseOrderItem.setUpdatedBy(user.getUserName());
                purchaseOrderItem.setUpdatedDate(new Date());
                purchaseOrderDAO.update(purchaseOrderItem);
                JOptionPane.showMessageDialog(this, GlobalConstant.MSG_UPDATE);
                listPurchaseOrderItem = purchaseOrderItemDAO.getDataByEquals(PurchaseOrderItem.class, "nomerPO", (String) comboNoPO.getSelectedItem());
                updateData();
            } catch (Exception ex) {
                Logger.getLogger(PurchaseOrderFrame.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
}//GEN-LAST:event_buttonUpdate2ActionPerformed

    private void buttonDelete2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonDelete2ActionPerformed
        int response = JOptionPane.showConfirmDialog(null, GlobalConstant.PROCCESS, GlobalConstant.CONFIRM, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
        if (response == JOptionPane.YES_OPTION) {
            try {
                PurchaseOrderItem purchaseOrderItem = listPurchaseOrderItem.get(tableData1.getSelectedRow());
                PurchaseOrder purchaseOrder = listPurchaseOrder.get(comboNoPO.getSelectedIndex());
                if (boxTunai.isSelected()) {
                    purchaseOrder.setPembayaran(boxTunai.getText());
                }
                if (boxCredit.isSelected()) {
                    purchaseOrder.setPembayaran(boxCredit.getText());
                }
                if (purchaseOrder.getPembayaran() == null) {
                    JOptionPane.showMessageDialog(this, "Tipe pembayaran Belum dipilih !!!");
                    return;
                }
                purchaseOrder.setJatuhTempo(dateJatuhTempo.getDate());
                purchaseOrder.setTotal(totals - purchaseOrderItem.getSubTotal());
                purchaseOrderItemDAO.delete(purchaseOrderItem, purchaseOrder);
                JOptionPane.showMessageDialog(this, GlobalConstant.MSG_DELETE);
                listPurchaseOrderItem = purchaseOrderItemDAO.getDataByEquals(PurchaseOrderItem.class, "nomerPO", (String) comboNoPO.getSelectedItem());
                updateData();
            } catch (Exception ex) {
                Logger.getLogger(PurchaseOrderFrame.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
}//GEN-LAST:event_buttonDelete2ActionPerformed

    private void tableData1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tableData1MouseClicked
        PurchaseOrderItem purchaseOrderItem = listPurchaseOrderItem.get(tableData1.getSelectedRow());
        comboNoPO.setSelectedItem(purchaseOrderItem.getNomerPO());
        textKodeBarcode.setText(purchaseOrderItem.getKodeBarcode());
        textNamaItem.setText(purchaseOrderItem.getNamaItem());
        textDescription.setText(purchaseOrderItem.getDescription());
        textHargaModal.setText(String.valueOf(purchaseOrderItem.getHargaModal()));
        textDiskon1.setText(String.valueOf(purchaseOrderItem.getDiskon1()));
        textDiskon3.setText(String.valueOf(purchaseOrderItem.getDiskon2()));
        textDiskon2.setText(String.valueOf(purchaseOrderItem.getDiskon3()));
        textDiskon4.setText(String.valueOf(purchaseOrderItem.getDiskon4()));
        textSubtotal.setText(String.valueOf(purchaseOrderItem.getSubTotal()));
        textQuantity.setText(String.valueOf(purchaseOrderItem.getQuantity()));
}//GEN-LAST:event_tableData1MouseClicked

    private void textQuantityKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_textQuantityKeyReleased
        textSubtotal.setText(String.valueOf(BigDecimal.valueOf(Double.parseDouble(textHargaModal.getText().equals(GlobalConstant.EMPTY_STRING) ? GlobalConstant.NOL : textHargaModal.getText())).multiply(BigDecimal.valueOf(textQuantity.getText().equals(GlobalConstant.EMPTY_STRING) ? Long.parseLong(GlobalConstant.NOL) : Long.parseLong(textQuantity.getText()))).setScale(2)));
}//GEN-LAST:event_textQuantityKeyReleased

    private void textDiskon4KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_textDiskon4KeyReleased
        BigDecimal diskon4 = (BigDecimal.valueOf(Double.parseDouble(textHargaModal.getText().equals(GlobalConstant.EMPTY_STRING) ? GlobalConstant.NOL : textHargaModal.getText())).divide(BigDecimal.valueOf(new Double(100)))).multiply(BigDecimal.valueOf(Double.parseDouble(textDiskon4.getText().equals(GlobalConstant.EMPTY_STRING) ? GlobalConstant.NOL : textDiskon4.getText())));
        textHargaModal.setText(String.valueOf(BigDecimal.valueOf(Double.parseDouble(textHargaModal.getText().equals(GlobalConstant.EMPTY_STRING) ? GlobalConstant.NOL : textHargaModal.getText())).subtract(diskon4).setScale(2)));
        textSubtotal.setText(String.valueOf(BigDecimal.valueOf(Double.parseDouble(textHargaModal.getText().equals(GlobalConstant.EMPTY_STRING) ? GlobalConstant.NOL : textHargaModal.getText())).multiply(BigDecimal.valueOf(textQuantity.getText().equals(GlobalConstant.EMPTY_STRING) ? Long.parseLong(GlobalConstant.NOL) : Long.parseLong(textQuantity.getText()))).setScale(2)));
}//GEN-LAST:event_textDiskon4KeyReleased

    private void textDiskon2KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_textDiskon2KeyReleased
        BigDecimal diskon2 = (BigDecimal.valueOf(Double.parseDouble(textHargaModal.getText().equals(GlobalConstant.EMPTY_STRING) ? GlobalConstant.NOL : textHargaModal.getText())).divide(BigDecimal.valueOf(new Double(100)))).multiply(BigDecimal.valueOf(Double.parseDouble(textDiskon2.getText().equals(GlobalConstant.EMPTY_STRING) ? GlobalConstant.NOL : textDiskon2.getText())));
        textHargaModal.setText(String.valueOf(BigDecimal.valueOf(Double.parseDouble(textHargaModal.getText().equals(GlobalConstant.EMPTY_STRING) ? GlobalConstant.NOL : textHargaModal.getText())).subtract(diskon2).setScale(2)));
        textSubtotal.setText(String.valueOf(BigDecimal.valueOf(Double.parseDouble(textHargaModal.getText().equals(GlobalConstant.EMPTY_STRING) ? GlobalConstant.NOL : textHargaModal.getText())).multiply(BigDecimal.valueOf(textQuantity.getText().equals(GlobalConstant.EMPTY_STRING) ? Long.parseLong(GlobalConstant.NOL) : Long.parseLong(textQuantity.getText()))).setScale(2)));
}//GEN-LAST:event_textDiskon2KeyReleased

    private void textDiskon3KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_textDiskon3KeyReleased
        BigDecimal diskon3 = (BigDecimal.valueOf(Double.parseDouble(textHargaModal.getText().equals(GlobalConstant.EMPTY_STRING) ? GlobalConstant.NOL : textHargaModal.getText())).divide(BigDecimal.valueOf(new Double(100)))).multiply(BigDecimal.valueOf(Double.parseDouble(textDiskon3.getText().equals(GlobalConstant.EMPTY_STRING) ? GlobalConstant.NOL : textDiskon3.getText())));
        textHargaModal.setText(String.valueOf(BigDecimal.valueOf(Double.parseDouble(textHargaModal.getText().equals(GlobalConstant.EMPTY_STRING) ? GlobalConstant.NOL : textHargaModal.getText())).subtract(diskon3).setScale(2)));
        textSubtotal.setText(String.valueOf(BigDecimal.valueOf(Double.parseDouble(textHargaModal.getText().equals(GlobalConstant.EMPTY_STRING) ? GlobalConstant.NOL : textHargaModal.getText())).multiply(BigDecimal.valueOf(textQuantity.getText().equals(GlobalConstant.EMPTY_STRING) ? Long.parseLong(GlobalConstant.NOL) : Long.parseLong(textQuantity.getText()))).setScale(2)));
}//GEN-LAST:event_textDiskon3KeyReleased

    private void textDiskon1KeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_textDiskon1KeyReleased
        BigDecimal diskon1 = (BigDecimal.valueOf(Double.parseDouble(textHargaModal.getText().equals(GlobalConstant.EMPTY_STRING) ? GlobalConstant.NOL : textHargaModal.getText())).divide(BigDecimal.valueOf(new Double(100)))).multiply(BigDecimal.valueOf(Double.parseDouble(textDiskon1.getText().equals(GlobalConstant.EMPTY_STRING) ? GlobalConstant.NOL : textDiskon1.getText())));
        textHargaModal.setText(String.valueOf(BigDecimal.valueOf(Double.parseDouble(textHargaModal.getText().equals(GlobalConstant.EMPTY_STRING) ? GlobalConstant.NOL : textHargaModal.getText())).subtract(diskon1).setScale(2)));
        textSubtotal.setText(String.valueOf(BigDecimal.valueOf(Double.parseDouble(textHargaModal.getText().equals(GlobalConstant.EMPTY_STRING) ? GlobalConstant.NOL : textHargaModal.getText())).multiply(BigDecimal.valueOf(textQuantity.getText().equals(GlobalConstant.EMPTY_STRING) ? Long.parseLong(GlobalConstant.NOL) : Long.parseLong(textQuantity.getText()))).setScale(2)));
}//GEN-LAST:event_textDiskon1KeyReleased

    private void textHargaModalKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_textHargaModalKeyReleased
        textSubtotal.setText(String.valueOf(BigDecimal.valueOf(Double.parseDouble(textHargaModal.getText().equals(GlobalConstant.EMPTY_STRING) ? GlobalConstant.NOL : textHargaModal.getText())).multiply(BigDecimal.valueOf(textQuantity.getText().equals(GlobalConstant.EMPTY_STRING) ? Long.parseLong(GlobalConstant.NOL) : Long.parseLong(textQuantity.getText()))).setScale(2)));
}//GEN-LAST:event_textHargaModalKeyReleased

    private void boxTunaiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_boxTunaiActionPerformed
        jLabel19.setVisible(false);
        dateJatuhTempo.setVisible(false);
    }//GEN-LAST:event_boxTunaiActionPerformed

    private void boxCreditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_boxCreditActionPerformed
        jLabel19.setVisible(true);
        dateJatuhTempo.setVisible(true);
    }//GEN-LAST:event_boxCreditActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JCheckBox boxCredit;
    private javax.swing.JCheckBox boxTunai;
    private javax.swing.JButton buttonDelete;
    private javax.swing.JButton buttonDelete2;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JButton buttonPrint;
    private javax.swing.JButton buttonReset;
    private javax.swing.JButton buttonReset2;
    private javax.swing.JButton buttonSave;
    private javax.swing.JButton buttonSave2;
    private javax.swing.JButton buttonUpdate;
    private javax.swing.JButton buttonUpdate2;
    private javax.swing.JComboBox comboNoPO;
    private javax.swing.JComboBox comboSearch;
    private javax.swing.JComboBox comboSupplier;
    private javax.swing.JComboBox comboUser;
    private org.jdesktop.swingx.JXDatePicker dateJatuhTempo;
    private org.jdesktop.swingx.JXDatePicker datePO;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel12;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTable tableData;
    private javax.swing.JTable tableData1;
    private javax.swing.JTextField textDescription;
    private javax.swing.JTextField textDiskon1;
    private javax.swing.JTextField textDiskon2;
    private javax.swing.JTextField textDiskon3;
    private javax.swing.JTextField textDiskon4;
    private javax.swing.JTextField textHargaModal;
    private javax.swing.JTextField textKodeBarcode;
    private javax.swing.JTextField textNamaItem;
    private javax.swing.JTextField textNoPO;
    private javax.swing.JTextField textQuantity;
    private javax.swing.JTextField textSearch;
    private javax.swing.JTextField textSubtotal;
    private javax.swing.JTextField textTotal;
    // End of variables declaration//GEN-END:variables

    private void updateData() {
        try {
            clearData();
//            listUser = userDAO.getAll(User.class);
            listSupplier = supplierDAO.getAll(Supplier.class);
            listPurchaseOrder = purchaseOrderDAO.getDataByEquals(PurchaseOrder.class, "status", GlobalConstant.N);
//            listPurchaseOrderItem = purchaseOrderItemDAO.getAll(PurchaseOrderItem.class);
            updateTable();
            updateTable1();
//            updateComboUser();
            updateComboSupplier();
            updateComboNoPO();
            updateComboCari();
            updateTotal();
        } catch (Exception ex) {
            Logger.getLogger(PurchaseOrderFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void clearData() {
        MyUniqueNumber myUniqueNumber = new MyUniqueNumber();
        myUniqueNumber.setDateUniqueNumber();
        textNoPO.setText(myUniqueNumber.getNoTransaksi());
        datePO.setDate(new Date());
        textKodeBarcode.setText(GlobalConstant.EMPTY_STRING);
        textNamaItem.setText(GlobalConstant.EMPTY_STRING);
        textDescription.setText(GlobalConstant.EMPTY_STRING);
        textHargaModal.setText(GlobalConstant.EMPTY_STRING);
        textDiskon1.setText(GlobalConstant.NOL);
        textDiskon3.setText(GlobalConstant.NOL);
        textDiskon2.setText(GlobalConstant.NOL);
        textDiskon4.setText(GlobalConstant.NOL);
        textSubtotal.setText(GlobalConstant.EMPTY_STRING);
        textQuantity.setText(GlobalConstant.SATU);
//        jPanel8.setVisible(false);
        jLabel3.setVisible(false);
        comboUser.setVisible(false);
        buttonUpdate.setVisible(false);
        buttonUpdate2.setVisible(false);
        jLabel19.setVisible(false);
        dateJatuhTempo.setVisible(false);
        boxTunai.setSelected(false);
        boxCredit.setSelected(false);
        buttonPrint.setVisible(false);
    }

    private void updateTable() {
        String[] judul = {GlobalConstant.NO, jLabel1.getText(), jLabel2.getText(), jLabel3.getText(), jLabel14.getText()};
        Object[][] isi = null;
        isi = new Object[listPurchaseOrder.size()][5];
        int x = 0;
        int no = 0;
        for (PurchaseOrder purchaseOrder : listPurchaseOrder) {
            isi[x][0] = no += 1;
            isi[x][1] = purchaseOrder.getNomerPO();
            isi[x][2] = purchaseOrder.getTanggalPO();
            isi[x][3] = purchaseOrder.getUser().getUserName();
            isi[x][4] = purchaseOrder.getSupplier().getNama();
            x++;
        }
        tableData.setModel(new DefaultTableModel(isi, judul) {

            @Override
            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return false;
            }
        });

        TableColumn column0 = tableData.getColumnModel().getColumn(0);
        column0.setPreferredWidth(75);
        column0.setMaxWidth(75);
        TableColumn column1 = tableData.getColumnModel().getColumn(1);
        column1.setPreferredWidth(150);
        column1.setMaxWidth(150);
        TableColumn column2 = tableData.getColumnModel().getColumn(2);
        column2.setPreferredWidth(200);
        column2.setMaxWidth(200);
    }

    private void updateTable1() {
        String[] judul = {GlobalConstant.NO, jLabel4.getText(), jLabel5.getText(), jLabel6.getText(), jLabel15.getText(), jLabel8.getText(), jLabel9.getText(), jLabel10.getText(), jLabel11.getText(), jLabel12.getText(), jLabel13.getText(), jLabel7.getText()};
        Object[][] isi = null;
        isi = new Object[listPurchaseOrderItem.size()][12];
        int x = 0;
        int no = 0;
        for (PurchaseOrderItem purchaseOrderItem : listPurchaseOrderItem) {
            isi[x][0] = no += 1;
            isi[x][1] = purchaseOrderItem.getNomerPO();
            isi[x][2] = purchaseOrderItem.getKodeBarcode();
            isi[x][3] = purchaseOrderItem.getNamaItem();
            isi[x][4] = purchaseOrderItem.getQuantity();
            isi[x][5] = numberFormat.format(purchaseOrderItem.getHargaModal());
            isi[x][6] = purchaseOrderItem.getDiskon1();
            isi[x][7] = purchaseOrderItem.getDiskon2();
            isi[x][8] = purchaseOrderItem.getDiskon3();
            isi[x][9] = purchaseOrderItem.getDiskon4();
            isi[x][10] = numberFormat.format(purchaseOrderItem.getSubTotal());
            isi[x][11] = purchaseOrderItem.getDescription();
            x++;
        }
        tableData1.setModel(new DefaultTableModel(isi, judul) {

            @Override
            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return false;
            }
        });

        TableColumn column0 = tableData1.getColumnModel().getColumn(0);
        column0.setPreferredWidth(75);
        column0.setMaxWidth(75);
        TableColumn column1 = tableData1.getColumnModel().getColumn(1);
        column1.setPreferredWidth(150);
        column1.setMaxWidth(150);
        TableColumn column2 = tableData1.getColumnModel().getColumn(2);
        column2.setPreferredWidth(150);
        column2.setMaxWidth(150);
        TableColumn column5 = tableData1.getColumnModel().getColumn(4);
        column5.setPreferredWidth(75);
        column5.setMaxWidth(75);
        TableColumn column6 = tableData1.getColumnModel().getColumn(5);
        column6.setPreferredWidth(200);
        column6.setMaxWidth(200);
        TableColumn column7 = tableData1.getColumnModel().getColumn(6);
        column7.setPreferredWidth(75);
        column7.setMaxWidth(75);
        TableColumn column8 = tableData1.getColumnModel().getColumn(7);
        column8.setPreferredWidth(75);
        column8.setMaxWidth(75);
        TableColumn column9 = tableData1.getColumnModel().getColumn(8);
        column9.setPreferredWidth(75);
        column9.setMaxWidth(75);
        TableColumn column10 = tableData1.getColumnModel().getColumn(9);
        column10.setPreferredWidth(75);
        column10.setMaxWidth(75);
        TableColumn column11 = tableData1.getColumnModel().getColumn(10);
        column11.setPreferredWidth(200);
        column11.setMaxWidth(200);
    }

    private void updateComboUser() {
        Object data[] = new Object[listUser.size()];
        int x = 0;
        for (User users : listUser) {
            data[x] = users.getUserName();
            x++;
        }
        comboUser.setModel(new DefaultComboBoxModel(data));
    }

    private void updateComboNoPO() {
        Object data[] = new Object[listPurchaseOrder.size()];
        int x = 0;
        for (PurchaseOrder purchaseOrder : listPurchaseOrder) {
            data[x] = purchaseOrder.getNomerPO();
            x++;
        }
        comboNoPO.setModel(new DefaultComboBoxModel(data));
    }

    private void updateComboSupplier() {
        Object data[] = new Object[listSupplier.size()];
        int x = 0;
        for (Supplier supplier : listSupplier) {
            data[x] = supplier.getNama();
            x++;
        }
        comboSupplier.setModel(new DefaultComboBoxModel(data));
    }

    private void updateComboCari() {
        Object[] dataClass = serviceHelper.getPropertyClass(PurchaseOrderItem.class);
        Object[] dataSearch = new Object[2];
        dataSearch[0] = dataClass[1];
        dataSearch[1] = dataClass[2];
        comboSearch.setModel(new DefaultComboBoxModel(dataSearch));
    }

    private void updateTotal() {
        double total = 0;
        for (PurchaseOrderItem purchaseOrderItem : listPurchaseOrderItem) {
            total += purchaseOrderItem.getSubTotal();
        }
        totals = total;
        textTotal.setText(numberFormat.format(total));
    }
}
